'use strict';
const db = uniCloud.database()
const coll = db.collection('userinfo')
exports.main = async (event, context) => {
	// let res = await coll.add(event)
	let res1 = await coll.where({
		name: event.name,
		password: event.password
	}).count()
	if (res1.total > 0) {
		return {
			errCode: 1,
			msg: '账号已存在，请重新注册'
		}
	} else {
		let obj = Object.assign(event, {
			total: 0
		})
		let res = await coll.add(obj)
		return res
	}



};
